<!--
*@Author: zt
*@Description: 新增文件详情
*@Date: 2024-08-20
-->
<template>
  <u-dialog v-bind="$attrs" @close="dialogClose" @submit="submit()">
    <a-layout class="f-h-100">
      <a-layout-content class="s-bg-white" style="overflow: auto">
        <a-space direction="vertical" class="f-w-100">
          <u-busi-card title="" :bordered="false">
            <u-field-upload
              v-model:value="fileData"
              :fileParams="{
                bucket: 'DOC_BIZ_TYPE_POLICY',
                biztype: '1',
              }"
            ></u-field-upload>
          </u-busi-card>
        </a-space>
      </a-layout-content>
    </a-layout>
  </u-dialog>
</template>

<script lang="ts" setup>
import { ref, reactive, computed, onMounted, h, useAttrs } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { _IFormEl, _IExtra } from '@/src/components/common/form/interface';
import { FormInstance, FormItemProps, message } from 'ant-design-vue';
import type { UploadChangeParam } from 'ant-design-vue';
import {
  HomeOutlined,
  FileTextOutlined,
  UploadOutlined,
} from '@ant-design/icons-vue';
import { TreeProps } from 'ant-design-vue/es/vc-tree';
import { ColumnProps } from 'ant-design-vue/es/table';
import { _IColumnProps } from '@/components/common/tableEdit/interface.ts';
import { fileCols } from '@/common/model/fileCols';
import { isSel } from '@/common/model/base';
import { watch } from 'vue';
import { alertC } from '@/util/common';
import * as knowledgeApi from '@/service/assist/knowledge';
import * as docApi from '@/service/assist/doc';

const attrs = useAttrs();
const route = useRoute();
const emit = defineEmits(['success']);
const formRef = ref<FormInstance>();
// const showUpload = ref(false)

const showUpload = ref(false);

const fileData = ref([]);

// 弹窗关闭
const dialogClose = () => {
  fileData.value = [];
  console.log('🚀 ~ dialogClose ~ fileData.value:', fileData.value);
};
//保存
const submit = async () => {
  if (fileData.value.length < 1) {
    return alertC('请选择文件上传');
  }
  fileData.value.map(e => {
    e['filename'] = e['name'];
  });
  const res = await knowledgeApi.add({
    appendixSaveVOList: fileData.value,
    ftype: attrs.ftype,
  });
  if (res.code == 0) {
    message.success('操作成功');
    showUpload.value = false;
    fileData.value = [];
    emit('success');
  }
};

watch(
  () => attrs.open,
  () => {
    fileData.value = [];
  }
);
</script>

<style lang="scss"></style>
